package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysUnionContent;
import com.ruoyi.system.service.ISysUnionContentService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * union资源Controller
 * 
 * @author ruoyi
 * @date 2024-09-26
 */
@RestController
@RequestMapping("/system/uninon_content")
public class SysUnionContentController extends BaseController
{
    @Autowired
    private ISysUnionContentService sysUnionContentService;

    /**
     * 查询union资源列表
     */
    @PreAuthorize("@ss.hasPermi('system:uninon_content:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysUnionContent sysUnionContent)
    {
        startPage();
        List<SysUnionContent> list = sysUnionContentService.selectSysUnionContentList(sysUnionContent);
        return getDataTable(list);
    }

    /**
     * 导出union资源列表
     */
    @PreAuthorize("@ss.hasPermi('system:uninon_content:export')")
    @Log(title = "union资源", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysUnionContent sysUnionContent)
    {
        List<SysUnionContent> list = sysUnionContentService.selectSysUnionContentList(sysUnionContent);
        ExcelUtil<SysUnionContent> util = new ExcelUtil<SysUnionContent>(SysUnionContent.class);
        util.exportExcel(response, list, "union资源数据");
    }

    /**
     * 获取union资源详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:uninon_content:query')")
    @GetMapping(value = "/{unioncontentId}")
    public AjaxResult getInfo(@PathVariable("unioncontentId") Integer unioncontentId)
    {
        return success(sysUnionContentService.selectSysUnionContentByUnioncontentId(unioncontentId));
    }

    /**
     * 新增union资源
     */
    @PreAuthorize("@ss.hasPermi('system:uninon_content:add')")
    @Log(title = "union资源", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysUnionContent sysUnionContent)
    {
        return toAjax(sysUnionContentService.insertSysUnionContent(sysUnionContent));
    }

    /**
     * 修改union资源
     */
    @PreAuthorize("@ss.hasPermi('system:uninon_content:edit')")
    @Log(title = "union资源", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysUnionContent sysUnionContent)
    {
        return toAjax(sysUnionContentService.updateSysUnionContent(sysUnionContent));
    }

    /**
     * 删除union资源
     */
    @PreAuthorize("@ss.hasPermi('system:uninon_content:remove')")
    @Log(title = "union资源", businessType = BusinessType.DELETE)
	@DeleteMapping("/{unioncontentIds}")
    public AjaxResult remove(@PathVariable Integer[] unioncontentIds)
    {
        return toAjax(sysUnionContentService.deleteSysUnionContentByUnioncontentIds(unioncontentIds));
    }
}
